<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="s" uri="/struts-tags" %>

<link rel="stylesheet" media="screen" href="css/docs.css"/>
<link rel="stylesheet" media="screen" href="lib/jqplot/jquery.jqplot.min.css"/>
<link rel="stylesheet" media="screen" href="lib/datatables/css/vpad.css"/>

<script type="text/javascript" src="${ctx}/js/global_util.js"></script>

<h1 class="page-title">HR审核 - 审核</h1>

<div class="container_12 clearfix leading">
    <div class="side grid_12 leading">
        <form class="form has-validation" id="post_form" name="post_form">
            <div class="clearfix">
                <div class="clearfix">
                    <label for="r_yes" class="form-label">是否允许离职</label>
                    <div class="form-input"><div class="radiogroup"><label><input type="radio" name="gender" id="r_yes" value="true" onclick="onRadioChanged(true)"/> 是</label> <label><input type="radio" id="r_no" name="gender" value="false" onclick="onRadioChanged(false)"/> 否</label></div></div>
                </div>
                <div class="clear"></div>

                <div class="clearfix">
                    <label for="leave_reason" class="form-label">离职原因</label>
                    <div class="form-input">
                        <select id="leave_reason">
                            <option>薪资低</option>
                            <option>公司福利差</option>
                            <option>工作环境不如意</option>
                            <option>不满公司的政策和措施</option>
                            <option>没有事业发展机会</option>
                            <option>缺少培训和机会</option>
                            <option>工作量太少</option>
                            <option>工作太枯燥</option>
                            <option>同事关系不融洽</option>
                            <option>与上司关系不和</option>
                            <option>找到更好的工作</option>
                            <option>自己经营生意</option>
                            <option>家庭原因</option>
                            <option>个人感情原因</option>
                            <option>求学深造</option>
                            <option>身体健康原因</option>
                            <option>转换行业</option>
                            <option>考上公务员</option>
                            <option>住所变迁</option>
                            <option>其他</option>
                        </select>
                    </div>
                </div>

                <div class="clearfix">
                    <label for="stay_date" class="form-label">预计留用时间</label>
                    <div class="form-input"><input type="text" id="stay_date" name="stay_date" placeholder="请输入预计留用时间" onfocus="WdatePicker({minDate:'%y-%M-%d'})" readonly="readonly" /></div>
                </div>


                <div class="clearfix">
                    <label for="stay_way" class="form-label">留用处理</label>
                    <div class="form-input">
                        <select id="stay_way">
                            <option>原职留用</option>
                            <option>部门异动</option>
                            <option>晋升异动</option>
                            <option>降职异动</option>
                            <option>其他</option>
                        </select>
                    </div>
                </div>

                <div class="form-action clearfix">
                    <button class="button" type="button" onclick="checkForm()">确定</button>
                    <button class="button" type="reset">取消</button>
                </div>
            </div>
        </form>
    </div>
</div>

<div class="clear"></div>

<script type="text/javascript" src="js/Tree.js"></script>
<script type="text/javascript">
    function onRadioChanged(value){
        if(value){
            $("#stay_way").attr("disabled", true)
            $("#stay_date").attr("disabled", false)
        }else{
            $("#stay_way").attr("disabled", false)
            $("#stay_date").attr("disabled", true)
        }
    }

    function checkForm() {
        var yes_class = $("#r_yes").parent("span").attr("class");
        var no_class = $("#r_no").parent("span").attr("class");
        var check_value = null;
        if(yes_class != undefined && yes_class.indexOf("checked") >= 0){
            check_value = "true";
        }
        if(no_class != undefined && no_class.indexOf("checked") >= 0){
            check_value = "false";
        }
        if(check_value != "true" && check_value != "false"){
            alert("请选择是否离职")
            return;
        }

        var stay_date = $("#stay_date").val();
        if (check_value == "true" && checkNull(stay_date)) {
            alert("请输入预计留用时间");
            return;
        }

        var data = {"hr_audit_result": check_value, "leave_reason":$("#leave_reason").val(), "stay_date":stay_date, "stay_way":$("#stay_way").val(), "apply.id":"${apply.id}"};
        var url = "${ctx}/leave/apply-hr-audit-save.xhtml";
        $.ajax(url, {
            type:"POST",
            data:data,
            dataType:"html",
            cache:false,
            success:function (a) {
                return pageDownloaded(a, url)
            },
            complete:function () {
            }
        });
    }
</script>